﻿using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using Abp.Runtime.Validation;
using NetCore.CustomAttributes;
using System;
using System.ComponentModel;

namespace NetCore.Dtos
{
    /// <summary>
    /// Dto基类
    /// </summary>
    [Serializable, Description("Dto基类")]

    public class BaseDto : BaseDto<int>
    {

    }
    [Serializable, Description("Dto泛型基类")]
    public abstract class BaseDto<TPrimaryKey> : IMayHaveTenant, IHasCreationTime, IHasModificationTime, ICustomValidate
    {
        /// <summary>
        /// Id字段
        /// </summary>
        [Description("Id字段")]
        public TPrimaryKey Id { get; set; }
        ///// <summary>
        ///// 创建人（外键）
        ///// </summary>
        //[Description("创建人")]
        //public TPrimaryKey CreatorId { get; set; }
        ///// <summary>
        ///// 修改人（外键）
        ///// </summary>
        //[Description("修改人")]
        //public TPrimaryKey LastModifierId { get; set; }

        ///// <summary>
        ///// 数据外键(组织机构/集团/公司/部门)
        ///// </summary>
        //[Description("数据外键")]
        //public TPrimaryKey OrganizationId { get; set; }

        /// <summary>
        /// 数据外键(组织机构/集团/公司/部门)
        /// </summary>
        [Description("数据外键")]
        public int? OrganizationId { get; set; }
        /// <summary>
        /// 创建人（外键）
        /// </summary>
        [Description("创建人")]
        public long? CreatorId { get; set; }
        /// <summary>
        /// 修改人（外键）
        /// </summary>
        [Description("修改人")]
        public long? LastModifierId { get; set; }


        /// <summary>
        /// 名称/模糊搜索
        /// </summary>
        [Description("名称")]
        public string Name { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        [Description("创建人")]
        public string CreatorName { get; set; }
        /// <summary>
        /// 修改人
        /// </summary>
        [Description("修改人")]
        public string LastModifierName { get; set; }
        /// <summary>
        /// 机构名称
        /// </summary>
        [Description("机构名称")]
        public string OrganizationName { get; set; }

        #region 实现接口字段
        /// <summary>
        /// 创建时间
        /// </summary>
        [Description("创建时间"), BaseField]
        public DateTime CreationTime { get; set; }
        /// <summary>
        /// 最近一次更新时间
        /// </summary>
        [Description("更新时间"), BaseField]
        public DateTime? LastModificationTime { get; set; }
        /// <summary>
        /// 删除时间
        /// </summary>
        [Description("删除时间"), BaseField]
        public DateTime? DeletionTime { get; set; }

        /// <summary>
        /// 租户
        /// </summary>
        [Description("租户"), BaseField]
        public int? TenantId { get; set; }
        #endregion

        public virtual void AddValidationErrors(CustomValidationContext context)
        {
            //throw new NotImplementedException();
        }
    }
}
